package com.asiainfo.bms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Swagger 配置类
 *
 * @author liu.hx
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {
    /**
     * 图书管理系统
     *
     * @return Docket实例
     */
    @Bean
    public Docket adminApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(adminApiInfo())
                .groupName("adminApi")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.asiainfo.bms.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * 管理系统api
     *
     * @return ApiInfo实例
     */
    private ApiInfo adminApiInfo() {
        return new ApiInfoBuilder()
                .title("图书管理系统API文档")
                .description("Mini MRD")
                .contact(new Contact("liu.hx", "http://horsenliu.gitee.io", "liu.hx"))
                .version("1.0")
                .build();
    }
}
